package com.khyr.service.impl;

import com.khyr.dao.BannerDao;
import com.khyr.entity.Banner;
import com.khyr.service.BannerService;
import com.khyr.vo.BannnerVo;
import com.khyr.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @className: BannerServiceImpl
 * @author: Zyl
 * @date: 2025/3/11 16:11
 * @Version: 1.0
 * @description:
 */
@Service
public class BannerServiceImpl implements BannerService {
    @Autowired
    private BannerDao bannerDao;
    @Override
    public R<List<Banner>> getBanner() {
        List<Banner> banners = bannerDao.selectList1();
        return new R<List<Banner>>(200,"查询成功",banners);

    }
    @Override
    public R<List<BannnerVo>> getBanner2() {
        List<Banner> banners = bannerDao.selectList1();
        List<BannnerVo> bannnerVoList = new ArrayList<>();
        for (Banner banner : banners) {
            BannnerVo bannerVo = new BannnerVo();
            bannerVo.setId(banner.getId().toString());
            bannerVo.setUrl(banner.getUrl());
            bannnerVoList.add(bannerVo);
        }
        return new R<List<BannnerVo>>(200, "查询成功", bannnerVoList);
    }
}
